package com.htl.controller;

import com.htl.mapper.UserMapper;
import com.htl.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hehehe
 * @ClassName UserController
 * @Description TODO
 * @date 2022/8/9 0009 15:56
 * @Version 1.0
 */

@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @GetMapping("/queryUserList")
    public List<User> queryUserList() {
        List<User> users = userMapper.queryUserList();
        return users;
    }

    @GetMapping("/queryUserById/{id}")
    public User queryUserById(@PathVariable Integer id) {
        User user = userMapper.queryUserById(id);
        return user;
    }

    @GetMapping("/addUser")
    public String addUser() {
        userMapper.addUser(new User(12, "张三丰", "963"));
        return "addUser OK";
    }

    @GetMapping("/updUser")
    public String updUser() {
        userMapper.updUser(new User(12, "李四", "741"));
        return "updUser OK";
    }

    @GetMapping("/delUser/{id}")
    public String delUser(@PathVariable Integer id) {
        userMapper.delUser(id);
        return "delUser OK";
    }


}
